package WaiBao;

import java.util.Arrays;

public class CaiTianYe {
    public static void main(String[] args) {
        String[] name = {"李泽宇(班长)", "张雪晴(组织委员)", "小李(学习委员)", "曹雪芹(组织委员)", "水浒传", "衫国演义", "猪八戒", "孙悟空", "沙和尚", "唐僧", "朱务农", "王德贵",
                "吕世界", "张得干", "李耀宇", "新吧", "王富贵", "李文清", "张浩宇", "李道伟", "李晨", "香香", "孙泽勋", "李茂贞", "李存勖", "李星云", "李浩男", "张发发",
                "王德鲁", "蔡天业(学生)"};//考生本人: 蔡天业(学生)
        int[] age = {19, 21, 21, 21, 18, 21, 19, 20, 20, 19, 18, 18, 20, 20, 18, 21, 20, 19, 18, 19, 19, 19, 20, 19, 20, 21, 21, 18, 19, 19};//最后一位：考生年龄:19

        double[] spring1 = {77, 80, 86, 74, 78, 97, 78, 89, 81, 84, 74, 81, 80, 76, 65, 68, 90, 99, 96, 88, 92, 91, 95, 65, 75, 74, 87, 76, 84, 94};
        double[] spring2 = {84, 82, 72, 84, 74, 77, 84, 74, 85, 77, 85, 74, 72, 85, 74, 75, 76, 69, 66, 98, 72, 71, 95, 86, 78, 88, 84, 87, 88, 96};
        double[] spring3 = {87, 67, 83, 85, 75, 69, 78, 69, 80, 80, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 82, 78, 79, 87, 96};


        double reli1;//代表每个学生的总分
        double reli2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            reli1 =spring1[i] + spring2[i] + spring3[i];
//            reli2= (reli1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + reli1);
//            System.out.println(name[i] + "的平均分为:" +reli2);
//        }


        double tunyun1 = 0, tunyun2 = 0;
        double[] jaiozi = new double[30];
//        for (int i = 0; i < 30; i++) {
//            tunyun1=spring1[i] +spring2[i] +spring3[i];
//            tunyun2 = (tunyun1* 1.0) / 3;
//            jaiozi[i] = tunyun2;
//        }
//
//        for (int i = 0; i < jaiozi.length - 1; i++) {
//            for (int j = 0; j <jaiozi.length - i - 1; j++) {
//                if (jaiozi[j] <jaiozi[j + 1]) {
//                    double tep = jaiozi[j];
//                    jaiozi[j] =jaiozi[j + 1];
//                    jaiozi[j + 1] = tep;
//                }
//            }
//        }
//
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(jaiozi[i]);
//        }


        double kaxio1 = 0, kaxio2 = 0, kaxio3 = 0;//计算每门课的平均分
        double bo1 = 0, bo2 = 0, bo3 = 0;//计算每门课标准差
        double dong1 = 0, dong2 = 0, dong3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < spring1.length; i++) {
            he += spring1[i];
        }
        kaxio1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + kaxio1);
        double Sum = 0;
        for (int i = 0; i < spring2.length; i++) {
            Sum += spring2[i];
        }
        kaxio2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + kaxio2);
        double sum = 0;
        for (int i = 0; i < spring3.length; i++) {
            sum += spring3[i];
        }
        kaxio3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + kaxio3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < spring1.length; i++) {
            c1 += (spring1[i] - kaxio1) * (spring1[i] -kaxio1);
        }
        bo1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" +bo1);
        for (int i = 0; i <spring2.length; i++) {
            c2 += (spring2[i] -kaxio2) * (spring2[i] -kaxio2);
        }
        bo2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +bo2);

        for (int i = 0; i <spring3.length; i++) {
            c3 += (spring3[i] - kaxio3) * (spring3[i] - kaxio3);
        }
        bo3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +bo3);
//////////
        Arrays.sort(spring1);
        Arrays.sort(spring2);
        Arrays.sort(spring3);
        dong1 = (spring1[15] +spring1[14]) * 1.0 / 2;
        dong2 = (spring2[15] +spring2[14]) * 1.0 / 2;
        dong3 = (spring3[15] +spring3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + dong1);
        System.out.println("农业设施设计与制造的中位数为:" + dong2);
        System.out.println("园艺植物设施栽培学的中位数为:" + dong3);
//    }
    }
}
